<?php 
require_once "includes/DB.class.php";
    $principal =  "";
    $nosotros =  "";
    $reservaciones =  "current" ;
    $torneos =  "" ;
    $galeria =  "" ;
    $contacto =  "" 
?>
<!DOCTYPE html>
<title>PaintBall Warriors</title>
<html lang="en">
<head>
  <title>Pa&aacute;ina Principal</title>
  <meta charset="utf-8">
  <meta name="description" content="Your description">
  <meta name="keywords" content="Your keywords">
  <meta name="author" content="Your name">
  <link rel="stylesheet" href="../css/reset.css" type="text/css" media="all">
  <link rel="stylesheet" href="../css/grid.css" type="text/css" media="all">
  <link rel="stylesheet" href="../css/style.css" type="text/css" media="all">
  
  <!-- styles for prettyPhoto -->
  <link rel="stylesheet" href="../css/prettyPhoto.css" type="text/css" media="all">
  
  <script type="text/javascript" src="../js/jquery-1.3.2.min.js"></script>
  <script type="text/javascript" src="../js/script.js"></script>
  <script type="text/javascript" src="../js/cufon-yui.js"></script>
  <script type="text/javascript" src="../js/flashobject.js"></script>
  <script type="text/javascript" src="../js/Bebas_400.font.js"></script>
  <script type="text/javascript" src="../js/cufon-replace.js"></script>

  <!--[if lt IE 9]>
  	<script type="text/javascript" src="js/html5.js"></script>
  <![endif]-->
  <!--[if lt IE 7]>
	<script type="text/javascript" src="http://info.template-help.com/files/ie6_warning/ie6_script_other.js"></script>
  <![endif]-->
</head>

<body>	
	<header>
		<div class="container_12">
			<div class="extra-wrap">
				<div class="grid_12">
					<div class="extra-wrap">
						<div class="grid_6 alpha omega">
							<div class="logo">
								<a href="main">Paintball Deporte y Recreaci&oacute;nes</a>
							</div>
						</div>
                                                <?php include "includes/header.php"; ?>
						<div class="clear"></div>
					</div>
				</div>
			</div>
			<div class="clear"></div>
		</div>
	</header>
	<section id="content">
		<div class="container_12">
			<div class="extra-wrap">
				<div class="grid_12">
					<div class="indent1">
						<div class="wrapper ">
                                                                      
                                                    <div class="col-indent">
                                                            <h1 class="h1-pad">reservaciones <?php echo "($fecha2)"; ?></h1>


                                                                <center>
                                                                    <div class="slider-indent calendarInsertResv" style="margin-bottom: 30px;">

                                                                            <div id="slider">
                                                                                <?php

                                                                                 //This gets today's date 
                                                                                 $date =time () ; 

                                                                                 //This puts the day, month, and year in seperate variables 
                                                                                 $day = date('d', $date) ; 
                                                                                 $month = date('m', $date) ; 
                                                                                 $year = date('Y', $date) ;

                                                                                 //Here we generate the first day of the month 
                                                                                 $first_day = mktime(0,0,0,$month, 1, $year) ; 

                                                                                 //This gets us the month name 
                                                                                 $title = date('F', $first_day) ; 

                                                                                 //Here we find out what day of the week the first day of the month falls on 
                                                                                 $day_of_week = date('D', $first_day) ; 

                                                                                 //Once we know what day of the week it falls on, we know how many blank days occure before it. If the first day of the week is a Sunday then it would be zero
                                                                                 switch($day_of_week){ 
                                                                                         case "Sun": $blank = 0; break; 
                                                                                         case "Mon": $blank = 1; break; 
                                                                                         case "Tue": $blank = 2; break; 
                                                                                         case "Wed": $blank = 3; break; 
                                                                                         case "Thu": $blank = 4; break; 
                                                                                         case "Fri": $blank = 5; break; 
                                                                                         case "Sat": $blank = 6; break; 
                                                                                 }

                                                                                 //We then determine how many days are in the current month
                                                                                 $days_in_month = cal_days_in_month(0, $month, $year) ; 
                                                                                ?>

                                                                                 <div>
                                                                                    <h6 class="h6-pad">
                                                                                        <?php 
                                                                                            setlocale(LC_TIME, 'spanish');
                                                                                            echo strftime("%B",mktime(0, 0, 0, $month, 1, 2000))  . "&nbsp;" . $year; ?>
                                                                                    </h6>
                                                                                    <table class="calendar none1">
                                                                                        <thead>
                                                                                            <tr>
                                                                                                <th>D</th>
                                                                                                <th>L</th>
                                                                                                <th>K</th>
                                                                                                <th>M</th>
                                                                                                <th>J</th>
                                                                                                <th>V</th>
                                                                                                <th>S</th>
                                                                                            </tr>
                                                                                        </thead>
                                                                                    </table>
                                                                                    <table class="calendar">
                                                                                            <tbody>

            <?php

                    $day_count = 1;
                    echo "<tr>";

                    //first we take care of those blank days

                     while ( $blank > 0 ) { 

                            echo "<td></td>"; 
                            $blank = $blank-1; 
                            $day_count++;

                    } 

                    //sets the first day of the month to 1 

                    $day_num = 1;

                    //count up the days, untill we've done all of them in the month
                    
                    while ( $day_num <= $days_in_month ) { 
                                    $habil = true;
                                    $halfFull = false;
                                    $fecha = $year .  "-" . $month . "-" . $day_num;

                                    if($day_count == 1  ){
                                        $habil = false;
                                    }
                                    
                                    $db = DB::Instance();
                                    $sql = "SELECT count(*) as reservas FROM `reservas` WHERE fecha = '$fecha' and estado = 'Confirmada'";
                                    
                                    $data = $db->query($sql);

                                    $reservas = $data->fetchAll();
                                    switch ( $reservas[0]["reservas"] ){
                                        case 0:
                                            break;
                                        case 1:
                                        case 2:
                                            $halfFull = true;
                                            break;
                                        case 3;
                                            $habil = false;
                                            break;
                                    }
                                    if($habil){
                                       if($halfFull){
                                            echo "<td class=\"halfReservation\"><a href=\"reservacion?fecha=$fecha\" >" . $day_num . "</a></td>"; 
                                       } else{
                                            echo "<td><a href=\"reservacion?fecha=$fecha\" >" . $day_num . "</a></td>"; 
                                       }
                                    } else {
                                        echo "<td class=\"active normaltip\" title=\"No hay Disponibilidad\">" . $day_num . "</td>"; 
                                    }
                                    $day_num++; 
                                    $day_count++;

                                    //Make sure we start a new row every week
                                    if ($day_count > 7){
                                                    echo "</tr><tr>";
                                                    $day_count = 1;
                                    }
                    } 
                    //Finaly we finish out the table with some blank details if needed

                    while ( $day_count >1 && $day_count <=7 )  { 
                            echo "<td></td>"; 
                            $day_count++; 
                    } 

                    echo "</tr>"; 
            ?>


                                                                                            </tbody>
                                                                                    </table>
                                                                                 </div>
                                                                                </div>
                                                                            <a href="#" class="next1"><img src="../images/next-link1.png" alt="" /></a>
                                                                            <a href="#" class="prev1"><img src="../images/prev-link1.png" alt="" /></a>

                                                                    </div>
                                                                </center>                                                                

                                                            <div class="insertReservacion right">
                                                                <table>
                                                                    <form id="reservaform" action="insertReservacion" method="GET"> 
                                                                        <?php
                                                                            echo "<input type=\"hidden\" name=\"fecha2\" value=\"$fecha2\"";
                                                                        ?>
                                                                     <tr>
                                                                        <td>Horario</td>
                                                                        <td>
                                                                              <?php
                                                                               
                                                                               if($reserva2[0]){
                                                                                   echo '<input type="radio" name="horario" value="08:00am_11:00am">08:00am - 11:00am<br>';
                                                                               } else {
                                                                                    echo '<input type="radio" name="horario" value="08:00am_11:00am" disabled>08:00am - 11:00am <b>No Disponible</b><br>';
                                                                               }
                                                                               if($reserva2[1]){
                                                                                   echo '<input type="radio" name="horario" value="11:00am_02:00pm">11:00am - 02:00pm<br>';
                                                                               } else {
                                                                                    echo '<input type="radio" name="horario" value="11:00am_02:00pm" disabled>11:00am - 02:00pm <b>No Disponible</b><br>';
                                                                               }
                                                                               if($reserva2[2]){
                                                                                   echo '<input type="radio" name="horario" value="02:00pm_05:00pm">02:00pm - 05:00pm<br>';
                                                                               } else {
                                                                                    echo '<input type="radio" name="horario" value="02:00pm_05:00pm" disabled>02:00pm - 05:00pm <b>No Disponible</b><br>';
                                                                               }
                                                                              
                                                                              
                                                                               ?>   
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td>Nombre</td>
                                                                        <td>
                                                                            <table>
                                                                                
                                                                                <tr>
                                                                                    <td> <input type="Text" name="nombre"> </td>
                                                                                    <td> <input type="Text" name="apellido1"> </td>
                                                                                    <td> <input type="Text" name="apellido2">  </td>
                                                                                </tr>
                                                                               <tr>
                                                                                    <td>Nombre</td>
                                                                                    <td>Primer Apellido</td>
                                                                                    <td>Segundo Apellido</td>
                                                                                </tr>
                                                                                
                                                                            </table>
                                                                           
                                                                        </td>
                                                                    </tr>
                                                                     <tr>
                                                                        <td>Numero Personas</td>
                                                                        <td><input type="Text" name="cantidadPersonas"></td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td>Correo Electronico</td>
                                                                        <td><input type="Text" name="email"></td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td>Numero de Telefono</td>
                                                                        <td><input type="Text" name="telefono"></td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td colspan="2"><input class="right" type="submit" value="Enviar"> </td>
                                                                    </tr>
                                                                    </form>
                                                                 </table>
                                                            </div>
                                                            
                                                    </div>
                                                    

						</div>
					</div>
				</div>
				<div class="clear"></div>
			</div>
		</div>
	</section>
        <?php include "includes/footer.php" ?>

  <script type="text/javascript"> Cufon.now(); </script>
</body>
</html>
